普通 (1) | void operator delete (void* ptr) throw(); |
---|---|
nothrow (2) | void operator delete (void* ptr, const std::nothrow_t& nothrow_constant) throw(); |
placement (3) | void operator delete (void* ptr, void* voidptr2) throw(); |
普通 (1) | void operator delete (void* ptr) noexcept; |
---|---|
nothrow (2) | void operator delete (void* ptr, const std::nothrow_t& nothrow_constant) noexcept; |
placement (3) | void operator delete (void* ptr, void* voidptr2) noexcept; |
普通 (1) | void operator delete (void* ptr) noexcept; |
---|---|
nothrow (2) | void operator delete (void* ptr, const std::nothrow_t& nothrow_constant) noexcept; |
placement (3) | void operator delete (void* ptr, void* voidptr2) noexcept; |
带大小 (4) | void operator delete (void* ptr, std::size_t size) noexcept; |
nothrow 带大小 (5) | void operator delete (void* ptr, std::size_t size, const std::nothrow_t& nothrow_constant) noexcept; |
::operator delete(ptr)
。::operator delete(ptr)
。operator delete
的重载都在全局命名空间中声明,而不是在 std 命名空间内。<new>
。operator delete
是一个常规函数,可以像任何其他函数一样显式调用。但在 C++ 中,delete
是一个具有非常特定行为的运算符:带有 delete
运算符的表达式首先调用适当的析构函数(对于类类型),然后调用*析构函数*。operator delete
的成员函数(如果存在)。在所有其他情况下,它是全局函数 operator delete
(即此函数——或更具体的重载)。如果 delete
表达式前面带有*作用域运算符*(即 ::operator delete
),则只考虑全局*析构函数*。delete
表达式始终调用单参数签名(例如(1))。delete
表达式始终使用接受指针(例如(1))或指针和大小(例如(4))的签名。总是优先使用带*size*的版本(4),除非重载提供了与指针类型更匹配的匹配。delete
运算符始终调用此函数的普通版本,并且每个参数只调用一次)。这些其他签名仅在对象构造失败时由*new表达式*自动调用(例如,如果对象的构造函数在由带 nothrow 的*new表达式*构造时抛出异常,则会调用接受 nothrow 参数的匹配 operator delete 函数)。void*
。operator new
返回,并且尚未通过先前调用此函数被释放。operator new
返回,并且尚未通过先前调用此函数被释放。
|
|
MyClass constructed MyClass destroyed |